C#
VB
C++
Represents a generic collection of objects.
[SerializableAttribute()][DefaultMemberAttribute("Item")]public class RasterCollection<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
<SerializableAttribute()>Public Class RasterCollection(Of T)Implements System.Collections.Generic.ICollection(Of T), System.Collections.Generic.IEnumerable(Of T), System.Collections.Generic.IList(Of T), System.Collections.IEnumerable
[SerializableAttribute()]generic<typename T>public ref class RasterCollection : public System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.IEnumerable
Type Parameters
T
A generic Type parameter.
The class contains the ItemAdded and ItemRemoved events. These events will fire whenever objects are added or removed to/from the collection.
Sample to test the RasterCollection class.
using Leadtools;public void RasterCollectionExample(){RasterCollection<string> rc = new RasterCollection<string>();rc.ItemAdded += new EventHandler<RasterCollectionEventArgs<string>>(rasterCollection_ItemAdded);rc.ItemRemoved += new EventHandler<RasterCollectionEventArgs<string>>(rasterCollection_ItemRemoved);// add a few itemsstring item1 = "item 1";string item2 = "item 2";string item3 = "item 3";rc.Add(item1);rc.Add(item2);rc.Add(item3);// insert an itemstring newItem2 = "new item 2";rc.Insert(1, newItem2);// check if collection contains this new itemAssert.IsTrue(rc.Contains(newItem2));// remove this new itemrc.Remove(newItem2);Assert.IsTrue(!rc.Contains(newItem2));// remove the last itemrc.RemoveAt(rc.Count - 1);Assert.IsTrue(rc.Count == 2);// send the first item to the end of the collectionrc.SendToBack(item1, true);Assert.IsTrue(rc.IndexOf(item1) == rc.Count - 1);// bring it back to the frontrc.BringToFront(item1, true);Assert.IsTrue(rc.IndexOf(item1) == 0);// copy to an arraystring[] items = new string[rc.Count];rc.CopyTo(items, 0);Assert.IsTrue(items.Length == rc.Count);for (int i = 0; i < items.Length; i++)Assert.IsTrue(items[i] == rc[i]);// loop throw the items and show themforeach (string str in rc)Console.WriteLine(str);// clean the collectionrc.Clear();Assert.IsTrue(rc.Count == 0);}private void rasterCollection_ItemAdded(System.Object sender, RasterCollectionEventArgs<string> e){Console.WriteLine("The Item ((" + e.Item.ToString() + ")) Has been added to the collection");}private void rasterCollection_ItemRemoved(System.Object sender, RasterCollectionEventArgs<string> e){Console.WriteLine("The Item ((" + e.Item.ToString() + ")) Has been removed from the collection");}
Imports LeadtoolsPublic Sub RasterCollectionExample()Dim rc As RasterCollection(Of String) = New RasterCollection(Of String)()AddHandler rc.ItemAdded, AddressOf rasterCollection_ItemAddedAddHandler rc.ItemRemoved, AddressOf rasterCollection_ItemRemoved' add a few itemsDim item1 As String = "item 1"Dim item2 As String = "item 2"Dim item3 As String = "item 3"rc.Add(item1)rc.Add(item2)rc.Add(item3)' insert an itemDim newItem2 As String = "new item 2"rc.Insert(1, newItem2)' check if collection contains this new itemDebug.Assert(rc.Contains(newItem2))' remove this new itemrc.Remove(newItem2)Debug.Assert((Not rc.Contains(newItem2)))' remove the last itemrc.RemoveAt(rc.Count - 1)Debug.Assert(rc.Count = 2)' send the first item to the end of the collectionrc.SendToBack(item1, True)Debug.Assert(rc.IndexOf(item1) = rc.Count - 1)' bring it back to the frontrc.BringToFront(item1, True)Debug.Assert(rc.IndexOf(item1) = 0)' copy to an arrayDim items As String() = New String(rc.Count - 1) {}rc.CopyTo(items, 0)Debug.Assert(items.Length = rc.Count)Dim i As Integer = 0Do While i < items.LengthDebug.Assert(items(i) = rc(i))i += 1Loop' loop throw the items and show themFor Each str As String In rcConsole.WriteLine(str)Next str' clean the collectionrc.Clear()Debug.Assert(rc.Count = 0)End SubPrivate Sub rasterCollection_ItemAdded(ByVal sender As System.Object, ByVal e As RasterCollectionEventArgs(Of String))Console.WriteLine("The Item ((" & e.Item.ToString() & ")) Has been added to the collection")End SubPrivate Sub rasterCollection_ItemRemoved(ByVal sender As System.Object, ByVal e As RasterCollectionEventArgs(Of String))Console.WriteLine("The Item ((" & e.Item.ToString() & ")) Has been removed from the collection")End Sub
using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;public void RasterCollectionExample(){RasterCollection<string> rc = new RasterCollection<string>();rc.ItemAdded += new EventHandler<RasterCollectionEventArgs<string>>(rasterCollection_ItemAdded);rc.ItemRemoved += new EventHandler<RasterCollectionEventArgs<string>>(rasterCollection_ItemRemoved);// add a few itemsstring item1 = "item 1";string item2 = "item 2";string item3 = "item 3";rc.Add(item1);rc.Add(item2);rc.Add(item3);// insert an itemstring newItem2 = "new item 2";rc.Insert(1, newItem2);// check if collection contains this new itemDebug.Assert(rc.Contains(newItem2));// remove this new itemrc.Remove(newItem2);Debug.Assert(!rc.Contains(newItem2));// remove the last itemrc.RemoveAt(rc.Count - 1);Debug.Assert(rc.Count == 2);// send the first item to the end of the collectionrc.SendToBack(item1, true);Debug.Assert(rc.IndexOf(item1) == rc.Count - 1);// bring it back to the frontrc.BringToFront(item1, true);Debug.Assert(rc.IndexOf(item1) == 0);// copy to an arraystring[] items = new string[rc.Count];rc.CopyTo(items, 0);Debug.Assert(items.Length == rc.Count);for (int i = 0; i < items.Length; i++)Debug.Assert(items[i] == rc[i]);// loop throw the items and show themforeach (string str in rc)Console.WriteLine(str);// clean the collectionrc.Clear();Debug.Assert(rc.Count == 0);}private void rasterCollection_ItemAdded(System.Object sender, RasterCollectionEventArgs<string> e){Console.WriteLine("The Item ((" + e.Item.ToString() + ")) Has been added to the collection");}private void rasterCollection_ItemRemoved(System.Object sender, RasterCollectionEventArgs<string> e){Console.WriteLine("The Item ((" + e.Item.ToString() + ")) Has been removed from the collection");}
Imports LeadtoolsImports Leadtools.CodecsPublic Sub RasterCollectionExample()Dim rc As RasterCollection(Of String) = New RasterCollection(Of String)()AddHandler rc.ItemAdded, AddressOf rasterCollection_ItemAddedAddHandler rc.ItemRemoved, AddressOf rasterCollection_ItemRemoved' add a few itemsDim item1 As String = "item 1"Dim item2 As String = "item 2"Dim item3 As String = "item 3"rc.Add(item1)rc.Add(item2)rc.Add(item3)' insert an itemDim newItem2 As String = "new item 2"rc.Insert(1, newItem2)' check if collection contains this new itemDebug.Assert(rc.Contains(newItem2))' remove this new itemrc.Remove(newItem2)Debug.Assert((Not rc.Contains(newItem2)))' remove the last itemrc.RemoveAt(rc.Count - 1)Debug.Assert(rc.Count = 2)' send the first item to the end of the collectionrc.SendToBack(item1, True)Debug.Assert(rc.IndexOf(item1) = rc.Count - 1)' bring it back to the frontrc.BringToFront(item1, True)Debug.Assert(rc.IndexOf(item1) = 0)' copy to an arrayDim items As String() = New String(rc.Count - 1) {}rc.CopyTo(items, 0)Debug.Assert(items.Length = rc.Count)Dim i As Integer = 0Do While i < items.LengthDebug.Assert(items(i) = rc(i))i += 1Loop' loop throw the items and show themFor Each str As String In rcConsole.WriteLine(str)Next str' clean the collectionrc.Clear()Debug.Assert(rc.Count = 0)End SubPrivate Sub rasterCollection_ItemAdded(ByVal sender As System.Object, ByVal e As RasterCollectionEventArgs(Of String))Console.WriteLine("The Item ((" & e.Item.ToString() & ")) Has been added to the collection")End SubPrivate Sub rasterCollection_ItemRemoved(ByVal sender As System.Object, ByVal e As RasterCollectionEventArgs(Of String))Console.WriteLine("The Item ((" & e.Item.ToString() & ")) Has been removed from the collection")End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
